﻿using Airborne.ScrumPoker.Model.TeamFoundation;
using Airborne.ScrumPoker.Module.TeamFoundation.Model;
using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.Unity;

namespace Airborne.ScrumPoker.Module.TeamFoundation
{
    public class TeamFoundationModule : IModule
    {
        private IUnityContainer Container { get; set; }

        public TeamFoundationModule(IUnityContainer container)
        {
            Container = container;
        }

        #region IModule Members

        public void Initialize()
        {
            RegisterComponents();
            Controllers.IWorkItemController workItemController = Container.Resolve<Controllers.IWorkItemController>();
            workItemController.Run();
        }

        private void RegisterComponents()
        {
            Container.RegisterType<TeamFoundationConfiguration>(new ContainerControlledLifetimeManager());
            Container.RegisterType<ITeamFoundationProxy, TeamFoundationProxy>(new ExternallyControlledLifetimeManager());
            Container.RegisterType<Views.IWorkItemSelectView, Views.WorkItemSelectView>(new ExternallyControlledLifetimeManager());
            Container.RegisterType<Controllers.IWorkItemController, Controllers.WorkItemController>(new ExternallyControlledLifetimeManager());
        }

        #endregion
    }
}
